class Banner {
    constructor() {

        this.init();
    }
}
$.extend(Banner.prototype, {
    init: function () {
        this.bannerLength = $('.long-banner-first').width();
        this.page = 0;
        this.timer = null;
        $('.go1').on('click', $.proxy(this.prePage, this));
        $('.go2').on('click', $.proxy(this.nextPage, this));
        this.interval();
    },
    prePage: function () {
        if (this.page === 0) {
            // clearInterval(this.timer);
            this.page = $('.long-banner').children().length - 1;
            $('.long-banner').css({ left: -this.bannerLength * this.page });
            this.page--;
        }
        else {
            this.page--;
        }
        this.pageGo();
    },
    nextPage: function () {
        $('.long-banner').stop();
        $('.long-banner').css({ left: -this.bannerLength * this.page });
        if (this.page === $('.long-banner').children().length - 1) {

            this.page = 0;
            $('.long-banner').css({ left: -this.bannerLength * this.page });
            this.page++;
        }
        else {
            this.page++;
        }
        this.pageGo();
    },
    pageGo: function () {

        clearInterval(this.timer);
        this.timer = null;
        $(".long-banner").animate({
            left: -this.bannerLength * this.page
        });
        this.interval();
    },
    interval: function () {
        this.timer =setInterval($.proxy(function(){this.nextPage()},this),1500)
    }

})
export default Banner;